{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# pandas 进阶修炼 ｜早起Python\n",
    "<br>\n",
    "\n",
    "**本习题由公众号【早起Python & 可视化图鉴】 原创，转载及其他形式合作请与我们联系（微信号`sshs321`)，未经授权严禁搬运及二次创作，侵权必究！**\n",
    "\n",
    "\n",
    "\n",
    "本习题基于 `pandas` 版本 `1.1.3`，所有内容应当在 `Jupyter Notebook` 中执行以获得最佳效果。\n",
    "\n",
    "不同版本之间写法可能会有少许不同，如若碰到此情况，你应该学会如何自行检索解决。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 1 - 数据加载与存储 "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "是的，常常被忽略的「<font color=#E36C07>**数据加载与存储**</font>」也大有门道且值得作为本套习题的开门之章。\n",
    "\n",
    "在一次数据分析的过程中，你可能只会读取或存储一两次数据集。\n",
    "\n",
    "**但若能灵活掌握各项设置，在读取阶段就将数据筛选、匹配、格式指定等操作完成，有时会为我们节省大量时间。**\n",
    "\n",
    "在本节习题中，我将 pandas 数据分析中常见的数据读取与存储操作进行整理。\n",
    "\n",
    "<font color=#E36C07>**既可以用于巩固、学习各种操作，也可以作为速查手册使用**</font>。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 初始化\n",
    "\n",
    "<br>\n",
    "\n",
    "该 `Notebook` 版本为**纯习题版**\n",
    "\n",
    "如果需要答案或者提示，可以微信搜索公众号「早起Python」获取！"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 1-1 数据读取"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 1 读取 Excel 文件\n",
    "\n",
    "<br>\n",
    "\n",
    "- 读取当前目录下 `某招聘网站数据.csv` 文件\n",
    "\n",
    "- 读取当前目录下 `TOP250.xlsx` 文件\n",
    "\n",
    "**注意**：使用 `pandas` 读取 `CSV` 与 读取 `xlsx` 格式的 `Excel` 文件方法大致相同\n",
    "\n",
    "因此接下来与 `Excel` 相关的操作均以 `CSV` 格式进行出题。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "data = pd.read_csv(\"某招聘网站数据.csv\")\n",
    "data = pd.read_excel(\"TOP250.xlsx\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 2 读取 Excel 文件｜指定位置\n",
    "\n",
    "在大多数情况下，我们会将 `notebook` 和数据源文件放在同一个目录（文件夹下），这样直接使用`pd.read_xxx(\"文件名\")`即可成功读取。\n",
    " \n",
    "但有时需要读取的文件和 `notebook` 不在同一个目录下，这时可以使用绝对路径或者相对本 `notebook` 的路径。\n",
    "\n",
    "现在请读取本套习题中第二章节下的数据，即 `2 - 个性化显示设置/data.csv`"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 104,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "###  3 读取 Excel 文件｜指定行（顺序）\n",
    "<br>\n",
    "\n",
    "读取当前目录下 `某招聘网站数据.csv` 文件的 <font color = '#5F5FFC'>前20行</font>"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "###  4 读取 Excel 文件｜指定行（跳过）\n",
    "<br>\n",
    "\n",
    "读取当前目录下 `某招聘网站数据.csv` 文件并<font color = '#5F5FFC'>跳过前20行</font>"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "###  5 读取 Excel 文件｜指定行（条件）\n",
    "<br>\n",
    "\n",
    "读取当前目录下 `某招聘网站数据.csv` 文件中全部<font color = '#5F5FFC'>偶数行</font>\n",
    "\n",
    "思考：如果是读取全部奇数行，或者更多满足指定条件的行呢？"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 6 读取 Excel 文件｜指定列（列号）\n",
    "\n",
    "<br>\n",
    "\n",
    "**根据指定列号读取**\n",
    "\n",
    "读取当前目录下 `某招聘网站数据.csv` 文件的第 `1、3、5` 列"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "###  7 读取 Excel 文件｜指定列（列名）\n",
    "\n",
    "<br>\n",
    "\n",
    "**根据指定列名读取**\n",
    "\n",
    "读取当前目录下 `某招聘网站数据.csv` 文件的 `positionId、positionName、salary` 列"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "###  8 读取 Excel 文件｜指定列（匹配）\n",
    "\n",
    "<br>\n",
    "\n",
    "**根据指定列名匹配读取**\n",
    "\n",
    "让我们来个更难一点的，还是读取 `某招聘网站数据.csv` 文件，但现在有一个 list 中包含多个字段👇\n",
    "\n",
    "`usecols = ['positionId','test','positionName', 'test1','salary']`\n",
    "\n",
    "如果 `usecols` 中的列名存在于 `某招聘网站数据.csv` 中，则读取。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 9 读取 Excel 文件｜指定索引\n",
    "\n",
    "<br>\n",
    "\n",
    "读取当前目录下 `某招聘网站数据.csv` 文件，并在读取时将 `positionId` 设置为索引列"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "###  10 读取 Excel 文件｜指定标题\n",
    "\n",
    "<br>\n",
    "\n",
    "\n",
    "读取当前目录下 `某招聘网站数据.csv` 文件的 `positionId、positionName、salary` 列，并将标题设置为 `ID、岗位名称、薪资`"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "###  11 读取 Excel 文件｜缺失值转换\n",
    "\n",
    "<br>\n",
    "\n",
    "\n",
    "读取当前目录下 `某招聘网站数据.csv` 文件，**并不将缺失值标记为 `NA`**\n",
    "\n",
    "思考：为什么要这样做？"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "###  12 读取 Excel 文件｜缺失值标记\n",
    "\n",
    "<br>\n",
    "\n",
    "\n",
    "读取当前目录下 `某招聘网站数据.csv` 文件，**并将`[]`标记为缺失值**\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 13 读取 Excel 文件｜忽略缺失值\n",
    "\n",
    "<br>\n",
    "\n",
    "读取当前目录下 `某招聘网站数据.csv` 文件，**但不处理缺失值**\n",
    "\n",
    "思考：和之前的有什么不同，为什么这么做？"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 14 读取 Excel 文件｜指定格式\n",
    "\n",
    "<br>\n",
    "\n",
    "读取当前目录下 `某招聘网站数据.csv` 文件，并将 `positionId,companyId` 设置为字符串格式"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 15 读取 Excel 文件｜指定格式（时间）\n",
    "\n",
    "<br>\n",
    "\n",
    "读取当前目录下 `某招聘网站数据.csv` 文件，并将 `createTime` 列设置为字符串格式"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 16 读取 Excel 文件｜分块读取\n",
    "\n",
    "\n",
    "<br>\n",
    "\n",
    "读取当前目录下 `某招聘网站数据.csv` 文件，要求返回一个可迭代对象，每次读取 10 行\n",
    "\n",
    "思考：为什么这样做？"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 58,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 17 读取 txt 文件｜常规\n",
    "\n",
    "<br>\n",
    "\n",
    "读取当前目录下 `Titanic.txt` 文件。\n",
    "\n",
    "注意：在接下来的几种格式文件读取中，对于之前重复的参数/功能将不再整理，仅介绍读取功能。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 83,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 18 读取 txt 文件｜含中文\n",
    "\n",
    "<br>\n",
    "\n",
    "读取当前目录下 `TOP250.txt` 文件。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 79,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 19 读取 JSON 文件\n",
    "\n",
    "\n",
    "\n",
    "<br>\n",
    "\n",
    "读取当前目录下 `某基金数据.json` 文件。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 175,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 20 读取 HDF5 文件\n",
    "\n",
    "<br>\n",
    "\n",
    "`HDF5`是一种特殊的文件格式，常见于在大规模存储数据上\n",
    "\n",
    "关于 `pandas` 与 `hdf5` 格式文件的操作较多，下面仅学习如何读取。\n",
    "\n",
    "读取当前目录下`store_tl.h5`文件"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 120,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "微信搜索公众号「早起Python」，关注后可以获得更多资源！"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 21 从剪贴板读取数据\n",
    "\n",
    "<br>\n",
    "\n",
    "打开当前目录下 `Titanic.txt` 文件，全选并复制。\n",
    "\n",
    "现在直接从剪贴板读取数据。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 102,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 22 从 SQL 读取数据\n",
    "\n",
    "<br>\n",
    "\n",
    "有时我们需要从 `SQL` 中读取数据，如果先将数据导出再`pandas`读取并不是一个合适的选择。\n",
    "\n",
    "在 `pandas` 中支持直接从 `sql` 中查询并读取。\n",
    "\n",
    "为了方便统一操作，请先执行下面的代码创建数据。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 121,
   "metadata": {},
   "outputs": [],
   "source": [
    "from sqlite3 import connect\n",
    "conn = connect(':memory:')\n",
    "df = pd.DataFrame(data=[[0, '10/11/12'], [1, '12/11/10']],\n",
    "                  columns=['int_column', 'date_column'])\n",
    "df.to_sql('test_data', conn)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "下面将 `SQL` 语句 `SELECT int_column, date_column FROM test_data` 转换为 `DataFrame`"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 123,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>int_column</th>\n",
       "      <th>date_column</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0</td>\n",
       "      <td>10/11/12</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1</td>\n",
       "      <td>12/11/10</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   int_column date_column\n",
       "0           0    10/11/12\n",
       "1           1    12/11/10"
      ]
     },
     "execution_count": 123,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 23 从网页读取数据\n",
    "\n",
    "<br>\n",
    "\n",
    "直接从东京奥运会官网读取奖牌榜数据。\n",
    "\n",
    "目标网站地址为 `https://olympics.com/tokyo-2020/olympic-games/zh/results/all-sports/medal-standings.htm`\n",
    "\n",
    "思考：什么类型的在线表格可以直接读取？"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 99,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 24 循环读取数据\n",
    "\n",
    "<br>\n",
    "\n",
    "在本小节 `demodata` 文件夹下有多个 `Excel` 文件，要求一次性循环读取全部文件"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 1-2 数据创建\n",
    "\n",
    "<br>\n",
    "\n",
    "除了直接读取本地文件，学会直接创建数据框也很重要，常见于测试一些函数，下面是从常见数据结构创建数据框的方法整理"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 25 从列表创建\n",
    "\n",
    "<br>\n",
    "\n",
    "将下面的 `list` 转换为 `dataframe`，并指定列名为`\"早起Python\"`"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 137,
   "metadata": {},
   "outputs": [],
   "source": [
    "l = [1,2,3,4,5]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 139,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 26 从列表创建｜嵌套列表\n",
    "\n",
    "<br>\n",
    "\n",
    "将下面的 `list` 转换为 `dataframe`，并指定行索引为`\"公众号\",\"早起Python\"`"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 150,
   "metadata": {},
   "outputs": [],
   "source": [
    "l = [[1,2,3],[4,5,6]]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 151,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "![公众号：早起Python](http://liuzaoqi.oss-cn-beijing.aliyuncs.com/2021/09/18/16319660121648.jpg?域名/sample.jpg?x-oss-process=style/stylename)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 27 从字典创建"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "执行下方代码，并将字典转换为`dataframe`"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 124,
   "metadata": {},
   "outputs": [],
   "source": [
    "d = {\n",
    "    \"one\": pd.Series([1.0, 2.0, 3.0], index=[\"a\", \"b\", \"c\"]),\n",
    "    \"two\": pd.Series([1.0, 2.0, 3.0, 4.0], index=[\"a\", \"b\", \"c\", \"d\"]) }"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 128,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 28 从字典创建｜指定索引\n",
    "\n",
    "<br>\n",
    "\n",
    "还是上一题的字典`d`，将其转换为`dataframe`并指定索引顺序为 `d、b、a`"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 29 从字典创建｜指定列名\n",
    "\n",
    "<br>\n",
    "\n",
    "还是上一题的字典`d`，将其转换为`dataframe`并指定索引顺序为 `d、b、a`，列名为`\"two\", \"three\"`"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 144,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 30 从字典创建｜字典列表\n",
    "<br>\n",
    "\n",
    "将下方列表型字典转换为`dataframe`\n",
    "\n",
    "思考：如何指定行/列索引？"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "d = [{\"a\": 1, \"b\": 2}, {\"a\": 5, \"b\": 10, \"c\": 20}]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 31 从集合创建\n",
    "\n",
    "<br>\n",
    "\n",
    "将下面的元组转换为 dataframe 且行列索引均为 `1,2,3,4`"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 163,
   "metadata": {},
   "outputs": [],
   "source": [
    "t =((1,0,0,0,),(2,3,0,0,),(4,5,6,0,),(7,8,9,10,))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 164,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 1-3 数据存储"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 32 保存为 CSV\n",
    "\n",
    "<br>\n",
    "\n",
    "将第三题读取到的数据保存为 `csv` 格式至当前目录下（文件名任意）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 184,
   "metadata": {},
   "outputs": [],
   "source": [
    "data = pd.read_csv(\"某招聘网站数据.csv\",nrows = 20)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 183,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 33 保存为 CSV｜指定列\n",
    "\n",
    "<br>\n",
    "\n",
    "将第三题读取到的数据保存为 `csv` 格式至当前目录下（文件名任意），且只保留`positionName、salary`两列"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 34 保存为 CSV｜取消索引\n",
    "\n",
    "<br>\n",
    "\n",
    "将第三题读取到的数据保存为 `csv` 格式至当前目录下（文件名任意），且取消每一行的索引"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 185,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 35 保存为 CSV｜标记缺失值\n",
    "\n",
    "<br>\n",
    "\n",
    "在上一题的基础上，在保存的同时，将缺失值标记为`'数据缺失'`"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 186,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 36 保存为CSV｜压缩\n",
    "\n",
    "<br>\n",
    "\n",
    "将上一题的数据保存至 `zip` 文件，解压后出现 `out.csv`"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 192,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 37 保存为 Excel \n",
    "\n",
    "<br>\n",
    "\n",
    "将第三题读取到的数据保存为 `xlsx` 格式至当前目录下（文件名任意）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 38 保存为 JSON\n",
    "\n",
    "将之前的数据保存为 `json` 格式至当前目录下（文件名任意）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 39 保存为 Markdown"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "将之前数据转换为 `markdown` 形式表格，这样可以直接复制进 `.md` 文件中使用"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 40 保存为 Html\n",
    "\n",
    "将之前的数据保存为 `html` 格式至当前目录下（文件名任意），并进行如下设置\n",
    "- 取消行索引\n",
    "- 标题居中对齐\n",
    "- 列宽100"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "![](http://liuzaoqi.oss-cn-beijing.aliyuncs.com/2021/09/16/16317972442543.jpg?域名/sample.jpg?x-oss-process=style/stylename)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.5"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": false,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {
    "height": "calc(100% - 180px)",
    "left": "10px",
    "top": "150px",
    "width": "384px"
   },
   "toc_section_display": true,
   "toc_window_display": true
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
